home *** CD-ROM | disk | FTP | other *** search
- Path: sun001.spd.dsccc.com!spd!jmccarty
- From: jmccarty@spd.dsccc.com (Mike McCarty)
- Newsgroups: comp.lang.c
- Subject: Re: Easiest way to center a string?
- Date: 14 Feb 1996 19:56:18 GMT
- Organization: DSC Communications Corporation, Plano, Texas USA
- Message-ID: <4ftep2$b8q@sun001.spd.dsccc.com>
- References: <4fobka$1st@parlor.hiwaay.net> <4frji4$gbl@gryphon.phoenix.net>
- NNTP-Posting-Host: aplo139.spd.dsccc.com
-
- In article <4frji4$gbl@gryphon.phoenix.net>,
- Bruce Wedding <brucew@phoenix.net> wrote:
- )
- )> I'm learning C, and one of my assignments requires that the output strings be
- )>centered on the screen. Is there a simple way of doing this that I have overlooked?
- )
- )Get the length of your string / 2, subtract it from the width of
- )your screen / 2. That is your starting point. Simple
- )
- )
- )Bruce D. Wedding Have Compiler, Will Travel!
- ) Perspicacious Programming Performed Promptly
- )Katy, Texas, USA, Planet Earth, Milkyway Galaxy, Known Universe
-
- Until you get a string too long. Then your screen is messed up.
-
- Mike
-
-
- ----
- char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
-
- I don't speak for DSC. <- They make me say that.
-